package com.own.core.main;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.breadcrumb.BreadCrumbBar;
import org.apache.wicket.model.Model;

import com.own.core.dyn.add.AddObjectPanel;
import com.own.core.dyn.list.ListObjectPanel;
import com.own.core.dyn.search.SimpleSearchPanel;
import com.own.core.html.component.OwnBreadCrumbBar;
import com.own.core.html.component.link.OwnAjaxLink;
import com.own.core.html.form.Label.OwnLabel;
import com.own.core.html.modal.ActionPanel;
import com.own.core.html.modal.OwnModalWindow;
import com.own.core.html.panel.OwnPanel;
import com.own.core.html.panel.empty.OwnEmptyPan;
import com.own.core.object.Dao;
import com.own.core.util.Action; 
import com.own.core.object.admin.pages.Page;
import com.own.core.util.Mode;
import com.own.util.ResourceUtil;

public class Home extends OwnPanel {

	private ListObjectPanel listPanel;
	private BreadCrumbBar bar;

	public Home(Page page) {
		super("panel");
		setOwnPage(page);
		initPanel();
	}

	public Home(String id, Page page) {
		super(id);
		setOwnPage(page);

	}

	public void initPanel() {

	

		// list panel
		if (listPanel == null) {
			listPanel = new ListObjectPanel(this);
		}
		listPanel.setMode(mode);
		listPanel.initPanel();
		addOrReplace(listPanel);
		
		
		// add bar
		bar = new OwnBreadCrumbBar("bar");
		setBreadCrumbModel(bar);
		addOrReplace(bar);
		bar.setActive(listPanel);
		bar.setVisible(false);

		OwnPanel ownPanel;
		if (mode != Mode.FULL) {
			ownPanel = new ActionPanel("actionPanel") {
				@Override
				public void closeButton(AjaxRequestTarget target) {
					getModalWindow().close(target);
				}
			};
		} else {

			ownPanel = new OwnEmptyPan("actionPanel");
		}

		addOrReplace(ownPanel);

	}

	public ListObjectPanel getListPanel() {
		return listPanel;
	}

	public void setListPanel(ListObjectPanel listPanel) {
		this.listPanel = listPanel;
	}

	public BreadCrumbBar getBar() {
		return bar;
	}

	public void setBar(BreadCrumbBar bar) {
		this.bar = bar;
	}

}
